﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Lswweb.Model;
using Lswweb.Common;
using Lswweb.Domain;

namespace Lswweb.Controls
{
    public class LogisticsRadioButtonList : RadioButtonList
    {
        protected override void OnInit(EventArgs e)
        {
            IList<LogisticsCompanyInfo> list = LogisticsCompanyServices.FindAll();
            if (State != null)
                list = list.Where(info => info.State == State).ToList();

            this.DataSource = list;
            this.DataTextField = "CompanyName";
            this.DataValueField = "Id";
            this.DataBind();
        }

        public StatusType? State { get; set; }

        public new int SelectedValue
        {
            get{ return base.SelectedValue.As<int>(); }
            set { base.SelectedValue = value.ToString(); }
        }
    }
}
